package view.common.struts;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ExceptionHandler;
import org.apache.struts.config.ExceptionConfig;

/**
 * @Archivo StrutsExceptionHandler.java
 * @Fecha                @Autor   @Cambios
 * 21/01/2011 02:45:14 PM       moshiro
 */
public class StrutsExceptionHandler extends ExceptionHandler {

    public StrutsExceptionHandler(String message, Exception exception) {
        params = null;
        this.exception = exception;
        this.message = message;
    }

    public StrutsExceptionHandler(String message, String params[], Exception exception) {

        this.params = null;
        this.exception = exception;
        this.message = message;
        this.params = params;
    }

    public StrutsExceptionHandler(String message, String params[]) {

        this.params = null;
        this.message = message;
        this.params = params;
    }

    public StrutsExceptionHandler(Exception exception) {
        params = null;
        this.exception = exception;
    }

    public StrutsExceptionHandler(Class source, String propertiesFileName, Throwable cause) {
        params = null;
    }

    public StrutsExceptionHandler(String message) {

        params = null;
        this.message = message;

    }

    public StrutsExceptionHandler() {

        params = null;

    }

    public String getMessage() {
        return message;
    }

    public String[] getParams() {
        return params;
    }

    public Exception getException() {
        return exception;
    }

    public void setException(Exception exception) {
        this.exception = exception;
    }

    public ActionForward execute(
            Exception ex, ExceptionConfig exConfig,
            ActionMapping mapping,
            ActionForm formInstance,
            HttpServletRequest request,
            HttpServletResponse response) throws ServletException {
        logger.warn("FRAMEWORK - " + ex.getMessage());
        ex.printStackTrace();
        return mapping.findForward("error");//Login
    }
    private static Logger logger = Logger.getLogger(StrutsExceptionHandler.class);
    private Exception exception;
    private String message;
    private String params[];
    private String prueba;
    private String error11;
}
